<template>
    <div class="contract-detial-page waiver-penalty-interest-detial" :class="isApprove ? 'approve':'no-approve'">
        <Detail
            :Obj="Obj"
            :spinShow="spinShow"
            :isSP="isSP"
            :isLoan="isLoan"
            :isApprove="isApprove"
            :pageParams="pageParams"
            :contractNo="contractNo"
            :dataDict="dataDict"
            :userInfo="userInfo"
            :roleType="roleType"
            @showSpin="showSpin"
            @closeSpin="closeSpin"
            @back="back"
        />
        <Spin size="large" fix v-if="spinShow"></Spin>
    </div>
</template>
<script>
    import {mapGetters} from "vuex";

    import {channelType, loanSupervisor} from "_p/basic/api/contract/channel-type/channel-type";
    import {getDictDataList} from "_p/basic/assets/contract/js/utils";

    import Detail from "./waiver-penalty-interest-detial";

    export default {
        name: "WaiverPenaltyInterestDetial",
        components: {Detail},
        data() {
            return {
                Obj: {},
                id: null,
                spinShow: false,
                isSP: null, // 是否是供应商
                isLoan: null,
                isApprove: null, //是否是审批页面
                pageParams: {},
                contractNo: null, //合同号
                // 放款模式(loanModel) 变更类型  变更主体(PersonRoleType) 还款银行(repaymentBank)
                dicttArr: ["loanModel", "PersonRoleType", "repaymentBank", "expeenseStatus"],
                dataDict: {}
            };
        },
        computed: {
            ...mapGetters({userInfo: "userInfo", roleType: "roles"})
        },
        created() {
            this.getParams();
        },
        mounted() {
            this.init();
            console.group("页面初始数据：");
            console.log("userInfo:", this.userInfo);
            console.log("pageParams:", this.pageParams);
            console.log("roleType:", this.roleType);
            console.log("isSP:", this.isSP);
            console.log("isApprove:", this.isApprove);
            console.log("contractNo:", this.contractNo);
            console.groupEnd();
        },
        methods: {
            init() {
                this.getDictDataList();
            },
            // 获取初始数据
            getParams() {
                const pageParams = this.afs.getPageParams(this);
                const {contractNo, caseNo, processStatus, editFlag, readOnly} = pageParams;
                this.readOnly = pageParams.readOnly === "read" ? true : false;
                this.pageParams = pageParams;
                this.contractNo = contractNo;
                this.caseNo = caseNo;
                if (pageParams.bizDataId === undefined) {
                    this.id = pageParams.id;
                } else {
                    this.id = pageParams.bizDataId;
                }
                this.Obj = {
                    caseNo,
                    contractNo,
                    process: readOnly,
                    roleType: this.isSP,
                    readOnly: this.readOnly,
                    editFlag: editFlag,
                    processStatus: processStatus,
                    id: this.id,
                    type: 'penaltyExempt'
                };
                this.isApprove =
                    !!processStatus &&
                    (processStatus === "repairedUnderReview" ||
                        processStatus === "underReview");
                this.isSP = channelType(this.$route.meta.params);
                this.isLoan = loanSupervisor(this.roleType);
            },
            getDictDataList() {
                getDictDataList(this.dicttArr).then(res => {
                    this.dataDict = res;
                });
            },
            showSpin() {
                this.spinShow = true;
            },
            closeSpin() {
                this.spinShow = false;
            },
            back() {
                //关闭页面
                this.afs.closeTab(this);
            }
        }
    };
</script>
<style lang="less">
    @import "../../../../styles/common/form.less";
</style>
